// @ts-ignore
/* eslint-disable */
import { request } from 'umi';

/** 获取角色列表 GET /api/role */
export async function rolePage(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RequestData>('/api/role', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

export async function roleList(
  options?: { [key: string]: any },
) {
  return request<API.RoleItem[]>('/api/role', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 更新角色 PUT /api/role */
export async function updateRole(body: API.RoleItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/role', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 添加角色 POST /api/role */
export async function addRole(body: API.RoleItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/role', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除角色 DELETE /api/role */
export async function removeRole(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/role', {
    method: 'DELETE',
    params: {
      ...options,
    },
    ...(options || {}),
  });
}


/** 删除角色 DELETE /api/role */
export async function batchRemoveRole(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/role/batchdel', {
    method: 'DELETE',
    params: {
      ...options,
    },
    ...(options || {}),
  });
}

/** 获取角色权限列表 GET /api/role/module */
export async function queryRoleModule(
  params: {
    // query
    /** 角色id */
    roleId?: number;
  },
  options?: { [key: string]: any },
) {
  return request<string[]>('/api/role/module', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 更新角色权限 POST /api/role/module */
export async function updateRoleModule(
  body: Record<string, any>,
  options?: { [key: string]: any },
) {
  return request<Record<string, any>>('/api/role/module', {
    method: 'POST',
    requestType: 'form',
    data: body,
    ...(options || {}),
  });
}
